{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑计划</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">课程类型：</label>
                            <div class="layui-input-block">
                                <input type="text" name="plan_typename" lay-verify="required" placeholder="课程类型"  value="{$info.plan_typename}" class="layui-input ">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">状态：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="plan_online" value="1" title="上架" {if $info.plan_online==1}checked{/if} />
                                <input type="radio" name="plan_online" value="2" title="下架" {if $info.plan_online==2}checked{/if} />
                            </div>
                        </div>
                        <!--xm-select-radio=""-->
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">选择老师：</label>
                            <div class="layui-input-block">
                                <select id="l_piano" lay-verify="required" name="plan_teacher" lay-search>
                                    <option value="">请选择</option>
                                    {foreach name="teachers" item="v"}
                                    <option value="{$v.user_id}" {if $info.plan_teacher==$v.user_id}selected{/if}>{$v.user_username}({$v.user_phone})</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">授课地址：</label>
                            <div class="layui-input-block">
                                <div id="container" style="width:100%;height:300px;margin-bottom:20px;"></div>
                                <div class="layui-inline" style="position: absolute;z-index: 10000;top:20px;right:0px;">
                                    <label class="layui-form-label">搜索</label>
                                    <div class="layui-input-inline">
                                        <input id='tipinput' type="text" class="layui-input" placeholder="请输入关键字">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">经度</label>
                                    <div class="layui-input-inline">
                                        <input type="text" lay-verify="required" value="{$info.plan_lon}" id="lon" name="lon" class="layui-input" placeholder="点击地图上的标记获取经度">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">纬度</label>
                                    <div class="layui-input-inline">
                                        <input type="text" lay-verify="required" value="{$info.plan_lat}" id="lat" name="lat" class="layui-input" placeholder="点击地图上的标记获取纬度">
                                    </div>
                                </div>
                                <div class="layui-inline layui-col-md8">
                                    <label class="layui-form-label">地址</label>
                                    <div class="layui-input-block">
                                        <input type="text" lay-verify="required" value="{$info.plan_address}" id="address" name="address" class="layui-input" placeholder="地址">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">授课地址类型：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="plan_way" value="1" title="学生家" {if $info.plan_way==1}checked{/if} />
                                <input type="radio" name="plan_way" value="2" title="琴行" {if $info.plan_way==2}checked{/if} />
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">上课时间：</label>
                            <div class="layui-input-block">
                                <input type="text" onfocus="wk.lay_date(this);" name="plan_start_time" readonly lay-verify="required" placeholder="上课时间"  value="{$info.plan_start_time}" class="layui-input ">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">上课时长(分钟)：</label>
                            <div class="layui-input-block">
                                <input type="number" name="plan_minus" lay-verify="number" placeholder="上课时长"  value="{$info.plan_minus}" class="layui-input ">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">主课/副课：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="plan_type" value="1" title="主课" {if $info.plan_type==1}checked{/if} />
                                <input type="radio" name="plan_type" value="2" title="副课" {if $info.plan_type==2}checked{/if} />
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">序号：</label>
                            <div class="layui-input-block">
                                <input type="text" name="plan_list" lay-verify="required" placeholder="序号，如：1-1"  value="{$info.plan_list}" class="layui-input ">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">排序：</label>
                            <div class="layui-input-block">
                                <input type="number" name="plan_sort" lay-verify="required" placeholder="值越小，越排在前面显示"  value="{$info.plan_sort}" class="layui-input ">
                            </div>
                        </div>
                        <input type="hidden" name="plan_id" value="{$plan_id}" />
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.10&key=b1c2db1116a93d1611b32c9c4d9535ad&plugin=AMap.Autocomplete,AMap.PlaceSearch"></script><!--高德-->
<script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script><!--高德-->
<script>
    wk.amap();
    layui.use(['form','upload','layedit'], function() {
        var form = layui.form;
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('planInfoEdit')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('Plan/planinfo')}?p_id="+{$p_id})
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
        form.on('select(role)', function(data){
            var pid = data.value;
            if(pid == ''){
                $('#l_student').empty();
            }else{
                $.ajax({
                    url:"{:url('admin/Course/getUserByPiano')}",
                    dataType: 'json',
                    data : 'pid='+pid,
                    type: 'post',
                    success: function (returndata) {
                        if(returndata.code == 200){
                            var data = returndata.msg;
                            $("#l_student").empty();//清空下拉框的值
                            $('#l_student').append(new Option('请选择学生', ' '));// 下拉菜单里添加元素
                            $.each(data, function (index, item) {
                                $('#l_student').append(new Option(item.name, item.id));// 下拉菜单里添加元素
                            });
                            layui.form.render("select");//重新渲染 固定写法
                        }else{
                            alert ('error');
                        }
                    }
                });
            }
        });
    });
</script>

</body>
</html>
